﻿using Business.Service;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using WoChu.Infrastructure.ModelCommmon;
using WoChu.Infrastructure.Web;
using WoChu.WMS.Application.Dto;
using WoChu.WMS.Entity;

namespace MvcAppWeb.Controllers
{
    public class ReportController : BaseDataController
    {
        /// <summary>
        /// 订单查漏
        /// </summary>
        /// <returns></returns>
        public ActionResult CheckOrderList()
        {
            return View();
        }

        public ActionResult OrderCheckList()
        {
            return View();
        }
        /// <summary>
        /// 订单查漏列表查询
        /// </summary>
        /// <param name="checkOrderIn"></param>
        /// <returns></returns>
        public JsonResult GetCheckOrderList(CheckOrderInput checkOrderIn)
        {
            SaleAPPService service = new SaleAPPService();
            int page = int.Parse(Request["page"].ToString());
            int rows = int.Parse(Request["rows"].ToString());
            PageInfo<CheckOrder, CheckOrderInput> pageInfo = new PageInfo<CheckOrder, CheckOrderInput>() { Condition = checkOrderIn, PageIndex = page, PageSize = rows };
            service.GetCheckOrderList(pageInfo);
            return Json(pageInfo);
        }

        /// <summary>
        /// 视频查询 
        /// </summary>
        /// <returns></returns>
        public ActionResult VideoView()
        {
            return View();
        }

        public ActionResult VideoViews()
        {
            return View();
        }

        /// <summary>
        /// 视频展示
        /// </summary>
        /// <returns></returns>
        public ActionResult VideoShow()
        {
            return View();
        }

        /// <summary>
        /// 视频展示
        /// </summary>
        /// <returns></returns>
        public ActionResult VideoShows()
        {
            return View();
        }
        /// <summary>
        /// 订单信息
        /// </summary>
        /// <param name="orderNo"></param>
        /// <returns></returns>
        public JsonResult GetCheckOrderVideo(string orderNo)
        {
            WMSToWCSTaskService task = new WMSToWCSTaskService();
            var list = task.GetCheckOrderInfo(orderNo);
            return Json(list);
        }
        /// <summary>
        /// 获取生成好的关联视频
        /// </summary>
        /// <param name="orderNo"></param>
        /// <returns></returns>
        public JsonResult GetCheckVideoList(SaleAPPVideo condition)
        {
            //if (string.IsNullOrEmpty(orderNo) || !subType.HasValue)
            //    return Json("");
            VideoService service = new VideoService();
            var list = service.GetCheckVideoList(condition);
            return Json(list);
        }

        /// <summary>
        /// 生成视频
        /// </summary>
        /// <param name="orderNo"></param>
        /// <returns></returns>
        [HttpPost]
        public JsonResult CreateVideo(SaleAPPVideo model)
        {
            var ajaxRet = new AjaxResult();
            try
            {
                VideoService service = new VideoService();
                
                model.CREATEUSER = this.CurrentUser.USERNAME;
                service.CreateVideo(model, _Log);
                ajaxRet.UserData = model.FILENAME;
                // var list = service.GetCheckVideoList(orderNo);
                return Json(ajaxRet.SetSuccess("生成成功"));
            }
            catch (Exception ex)
            {
                _Log.LogError(ex, "ReprotController的CreateVidoe");
                return Json(ajaxRet.SetError(ex,"生成失败"));
            }
        }
    }
}